home *** CD-ROM | disk | FTP | other *** search
- /*
- * Offscreen.c
- */
-
-
- #include "Offscreen.h"
- //#include "Standard Stuff.h"
-
- WindowOffscreen *DrawOffscreen(WindowPtr theWindow, short rightSlop)
-
- { WindowOffscreen *theOffscreen;
- GWorldPtr theWorld;
- short depth;
- Rect globalRect;
- OSErr theErr;
-
- if ((theOffscreen = (WindowOffscreen *) NewPtr(sizeof(WindowOffscreen))) == 0L) {
- return(0L);
- }
-
- SetPort(theWindow);
- GetGWorld(&theOffscreen->windowPort, &theOffscreen->windowDevice);
-
- globalRect = theWindow->portRect;
- LocalToGlobal((Point *) &globalRect.top);
- LocalToGlobal((Point *) &globalRect.bottom);
- globalRect.right += rightSlop;
-
-
- // if((*gPreferences)->useTempMemory) {
- theErr = NewGWorld(&theWorld, 0, &globalRect, 0L, 0L, useTempMem);
- // }
- // else {
- // theErr = NewGWorld(&theWorld, 0, &globalRect, 0L, 0L, 0);
- // }
-
-
- if (theErr == noErr) {
-
- SetGWorld(theWorld, 0L);
- if (! LockPixels(theWorld->portPixMap)) {
- DisposeGWorld(theWorld);
- DisposePtr((Ptr)theOffscreen);
- return(0L);
- }
-
- globalRect = theWorld->portRect;
- globalRect.right -= rightSlop;
- CopyBits(&theWindow->portBits,
- &((GrafPtr) theWorld)->portBits,
- &theWindow->portRect,
- &globalRect,
- srcCopy, 0L);
-
- theOffscreen->offscreenWorld = theWorld;
- theOffscreen->rightSlop = rightSlop;
- return(theOffscreen);
-
- } else {
-
- DisposePtr((Ptr)theOffscreen);
- return(0L);
-
- }
- }
-
-
-
-
- void DrawOnscreen(WindowOffscreen *theOffscreen)
-
- {
- Rect copyRect = theOffscreen->offscreenWorld->portRect;
-
- copyRect.right -= theOffscreen->rightSlop;
- if (theOffscreen) {
- SetGWorld(theOffscreen->windowPort, theOffscreen->windowDevice);
- CopyBits(&((GrafPtr) theOffscreen->offscreenWorld)->portBits,
- (BitMap *)&(theOffscreen->windowPort)->portPixMap,
- ©Rect,
- &theOffscreen->windowPort->portRect,
- srcCopy, 0L);
- UnlockPixels(theOffscreen->offscreenWorld->portPixMap);
- DisposeGWorld(theOffscreen->offscreenWorld);
- DisposePtr((Ptr) theOffscreen);
- }
- }
-
-
-